package com.fruitsales.collection.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fruitsales.cart.pojo.cart;
import com.fruitsales.collection.pojo.collection;
import com.fruitsales.collection.service.collectionService;
import com.fruitsales.goods.pojo.goods;

@Controller
public class collectionController {
	@Autowired
	private collectionService service;
	
	@RequestMapping("collection/add")
	public void Add(Integer uid  ,Integer gid, HttpServletRequest requeset ,HttpServletResponse response){

		goods goods = new goods();
		goods.setGid(gid);
		collection collection = new collection();
		collection.setGoods(goods);
		collection.setUid(uid);
		service.addCollection(collection);
	}
	
	@RequestMapping("collection/delete")
	public void delete(Integer coid ,  HttpServletRequest requeset ,HttpServletResponse response){
		
		service.delete(coid);
	}
	
	@ResponseBody
	@RequestMapping("collection/query")
	public List<collection> queryByUserId(Integer uid , HttpServletRequest requeset ,HttpServletResponse response){
		
		return service.queryByUserId(uid);
		
	}
}
